package com.xnfh.planting.viewmodel

import com.xnfh.common.bean.PlantOptionBean
import com.xnfh.framework.base.BaseViewModel
import com.xnfh.framework.bean.RespStateData
import org.json.JSONObject

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2023/12/15 17:34
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/12/15 17:34
 * @UpdateRemark: 更新说明
 */
class PlantOptionViewModel: BaseViewModel() {
    private var plantingViewModelRes = PlantOptionViewModelRes()

    val plantOptionList = RespStateData<List<PlantOptionBean>>()

    /**
     * 获取种植方案列表
     */
    fun requestPlantOptionList(provinceId: Long?,cityId:Long?,startTime: String?,cropId: Long?) = launch {
        val jsonObject = JSONObject()
        jsonObject.put("provinceId",provinceId)
        jsonObject.put("cityId",cityId)
        jsonObject.put("startTime",startTime)
        jsonObject.put("cropId",cropId)
        plantingViewModelRes.requestPlantOption(creatRequestBody(jsonObject.toString()),plantOptionList)
    }

}